package cases.chapter12.chapter1202;

import java.util.Scanner;

public class CaculateSpeed {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        System.out.println("请输入您要使用的交通工具名称：");
        String choice = in.nextLine();
        String transport = "fanshe." + choice; //”fanshe”必须是当前类所在的包名
        double a = 23, b = 24, c = 25;
        try {
            Common newtransport = (Common)
                    Class.forName(transport).newInstance();
            System.out.println(choice + " speed is : " +
                    "" + newtransport.getSpeed(a, b, c));
        } catch (InstantiationException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
    }
}
